/**
 * 
 */
package cn.softTank.BpelModelImpl;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import cn.softTank.BpelModel.Source;
import cn.softTank.BpelModel.Sources;

/**
 * @author Yuzone (smartzxy@gmail.com)
 * 
 */
public class SourcesImpl implements Sources {

	private List<Source> source;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.softTank.BpelModel.Sources#addSource(cn.softTank.BpelModel.Source)
	 */
	@Override
	public void addSource(Source source) {
		if (this.source == null)
			this.source = new ArrayList<Source>();
		this.source.add(source);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.Sources#getSource()
	 */
	@Override
	public List<Source> getSource() {
		return source;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.Sources#removeSourceAt(int)
	 */
	@Override
	public void removeSourceAt(int index) {
		if (source != null && index < source.size())
			source.remove(index);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.Sources#setSource(java.util.List)
	 */
	@Override
	public void setSource(List<Source> source) {
		this.source = source;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toElement()
	 */
	@Override
	public Element toElement() {
		Element e = DocumentHelper.createElement("sources");
		if (source != null)
			for (int i = 0; i < source.size(); i++) {
				e.add(source.get(i).toElement());
			}
		return e;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toXml()
	 */
	@Override
	public String toXml() {
		// TODO Auto-generated method stub
		return null;
	}

}
